package com.jvm.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;

public class Test {

    public static void main(String[] args) {
//        ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
//        MyService myService = ctx.getBean(MyService.class);
//        myService.doStuff();
//
//        ClassPathResource classPathResource = new ClassPathResource("");


//        ApplicationContext ctx = new ClassPathXmlApplicationContext("conf/appContext.xml");
//        MyService myService = ctx.getBean(MyService.class);

        ExecutorService service = new ThreadPoolExecutor(2,2,2,TimeUnit.MICROSECONDS,new LinkedBlockingQueue<>());

        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);

        service.execute(() -> {
            for (int i=0;i<list.size();i++){
                if (i==1){
                    list.remove(1);
                }
                System.out.println(Thread.currentThread().getName()+list.get(i));
            }
        });

        service.execute(() -> {
            for (int i=0;i<list.size();i++){
                System.out.println(Thread.currentThread().getName()+list.get(i));
            }
        });



        service.shutdown();

    }

}
